#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<unistd.h>
void test1()
{
  int fd = open("log.txt",O_WRONLY|O_CREAT,0666);
  if(fd<0)
  {
    perror("open");
    return;
  }

  close(1);
  dup2(fd,1);

  printf("hello dup2!!!\n");
  fprintf(stdout,"hello fprintf\n");
}

int main()
{
  test1();

  return 0;
}
